﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using YArchitech.LIB;
using QuickModel.Forms;

namespace QuickModel.LastFastModeling
{
	public class LastFastModelingRespondHanlder : IResponseHanlder
	{
		public void AddStartTime(DateTime inputDataTime)
		{
			this.startTime = inputDataTime;
		}

		public void AddEndTime(DateTime inputDataTime)
		{
			this.endTime = inputDataTime;
		}

		public void AddOneResponse(RevitModelRebuildResponse inputResponse)
		{
			this.lstResponse.Add(inputResponse);
		}

		public void HanlderResponse()
		{
			StringBuilder stringBuilder = new StringBuilder();
			int num = (from n in this.lstResponse
			where n.IfSucess && n.ThisBuildData != null && n.ThisBuildData.NeedResponse
			select n).Count<RevitModelRebuildResponse>();
			int num2 = (from n in this.lstResponse
			where n.ThisBuildData != null && !n.ThisBuildData.NeedResponse
			select n).Count<RevitModelRebuildResponse>();
			int num3 = this.lstResponse.Count - num2 - num;
			stringBuilder.AppendLine(string.Format("共转换成功{0}个，失败{1}个", num, num3));
			stringBuilder.AppendLine(string.Format("共耗时(S)：{0}", (this.endTime - this.startTime).Seconds.ToString()));
			Process currentProcess = Process.GetCurrentProcess();
			IntPtr mainWindowHandle = currentProcess.MainWindowHandle;
			YJKWindowHandle owner = new YJKWindowHandle(mainWindowHandle);
			TransResultForm transResultForm = new TransResultForm(stringBuilder.ToString());
			transResultForm.ShowDialog(owner);
			this.lstResponse = new List<RevitModelRebuildResponse>();
		}

		private DateTime startTime;

		private DateTime endTime;

		private List<RevitModelRebuildResponse> lstResponse = new List<RevitModelRebuildResponse>();
	}
}
